package llk.views.object
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import llk.controllers.LlkController;
	import llk.datas.vo.ItemVO;

	public class ItemView extends Sprite
	{
		private var _ctrl:LlkController;
		
		private var _itemVO:ItemVO;
		
		private var itemList:Array ;
		private var img:Bitmap;
		private var bmpd:BitmapData;
		public function ItemView( $ctrl:LlkController = null )
		{
			super( );
			if($ctrl){
				this._ctrl = $ctrl;
				this._ctrl.mouseTarget = this;
			}
			init();
		}
		
//		public function itemDisenable():void{
//			this.mouseChildren = false;
//			this.mouseEnabled = false;
//		}
		
		public function show( ):void {
			if( !img )img = new Bitmap;
			this.addChild( img );
			
			if(!bmpd)bmpd = new BitmapData(35,35);
			bmpd.draw((new itemList[_itemVO.type] as MovieClip));
			img.bitmapData = bmpd;
		}
		public function destroy( ):void {
			if( this ){
				this.parent.removeChild( this );
			}
		} 
		
		public function move( $x:Number , $y:Number):void {
			this.x = $x;
			this.y = $y;
		}
		
		private function init( ):void {
			this.buttonMode = true;
			if(_ctrl)_ctrl.mouse.clickFun = clickFun;
			itemList = [img_1,img_2,img_3,img_4,img_5];
		}
		private function clickFun( ):void{
			//鼠标点击交互
			if(_ctrl)_ctrl.logic.itemSelect(itemVO);
		}
		
		
		public function set itemVO( value:ItemVO ):void {
			_itemVO = value;
		}
		public function get itemVO( ):ItemVO {
			return _itemVO;
		}
		
	}
}